#include<func.h>
//创建子线程后，主线程cancel子线程，子线程中途就会被退出
void* pthread_func(void *p)
{
    printf("I am child thread\n");
    sleep(1);
    printf("you cat not see me\n");
    return NULL;
}

int main()
{
    pthread_t pthid;
    int ret=pthread_create(&pthid,NULL,pthread_func,NULL);
    THREAD_ERR_CHECK(ret,"pthread_creat");
    ret=pthread_cancel(pthid);//向子线程发送cancel信号
    THREAD_ERR_CHECK(ret,"pthread_cancel");
    ret=pthread_join(pthid,NULL);//等待子进程
    THREAD_ERR_CHECK(ret,"pthread_join");
    printf("I am main thread\n");
    return 0;
}